﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using memo;
using System.Collections.Generic;

namespace memoTest
{
    /// <summary>
    /// Class to test the functionality of Subtopics.
    /// Tests the constructors.
    /// </summary>
    [TestClass]
    public class SubTopicTest
    {
        /// <summary>
        /// Used only for the testing. The expected title in the test.
        /// </summary>
        private static string ExpectedTitle = "TitleName";
        /// <summary>
        /// Used only for the testing. The expected short description in the test.
        /// </summary>
        private static string ExpectedShortDescription = "ShortDescriptionText";

        /// <summary>
        /// Empty Constructor to speed up compilation.
        /// </summary>
        public SubTopicTest() { }

        /// <summary>
        /// Létrehoz egy Subtopicot Content nélkül és ellenőrzi, hogy a paraméterei a megadottak-e.
        /// </summary>
        [TestMethod]
        public void NewSubTopicTest_NoContents()
        {
            SubTopic SubTopicObj = new SubTopic(ExpectedTitle, ExpectedShortDescription);

            Assert.AreEqual(ExpectedTitle, SubTopicObj.Title);
            Assert.AreEqual(ExpectedShortDescription, SubTopicObj.ShortDescription);
            Assert.IsNull(SubTopicObj.Contents);
        }

        /// <summary>
        /// 2. konstruktor test1 
        /// </summary>
        [TestMethod]
        public void SubTopicConstructorTest()
        {
            Content ExpectedContent = new Content("Content");
            List<Content> ExpectedContentList = new List<Content>();

            ExpectedContentList.Add(ExpectedContent);

            SubTopic SubTopicObj = new SubTopic(ExpectedTitle, ExpectedShortDescription, ExpectedContentList);

            Assert.AreEqual(ExpectedTitle, SubTopicObj.Title);
            Assert.AreEqual(ExpectedShortDescription, SubTopicObj.ShortDescription);
            for (int i = 0; i < ExpectedContentList.Count; i++)
            {
                Assert.AreEqual(ExpectedContentList[i], SubTopicObj.Contents[i]);
            }
        }

        /// <summary>
        /// Létrehoz egy Subtopicot néhány darab Content-tel és ellenőrzi, hogy a paraméterei a konstruktorban megadottak-e.
        /// </summary>
        [TestMethod]
        public void NewSubTopicTest_ManyContent()
        {
            List<Content> ExpectedContentList = new List<Content>();
            Random rnd = new Random();

            int Length = rnd.Next(5, 20);

            for (int i = 0; i < Length; i++)
            {
                ExpectedContentList.Add(new Content("Content" + i));
            }

            SubTopic SubTopicObj = new SubTopic(ExpectedTitle, ExpectedShortDescription, ExpectedContentList);

            Assert.AreEqual(ExpectedTitle, SubTopicObj.Title);
            Assert.AreEqual(ExpectedShortDescription, SubTopicObj.ShortDescription);
            CollectionAssert.AreEqual(ExpectedContentList, SubTopicObj.Contents);
        }



    }
}
